<?php 
namespace Models;
/**
 * 管理员模型
 * @package Models
 * @author 江羿平<hugcolin@163.com>
 */
class Admin extends Model{

	protected $_table = 'admins';

	protected $_filter = FALSE;

	protected $_primekey = 'id';

	public $login_error = 0;

	
	/**
	 * 使用账号和密码登录
	 * @param   string  account    账号
	 * @param   string  password   密码
	 * @return  bool
	 */
	public function login($account,$password){
		
		$user = $this->where(array('account'=>$account))->get_one();
		if(!$user){
			$this->login_error = 50001;
			return FALSE;
		}
		$password = encrypt($password);		
		if($password != $user['password']){
			$this->login_error = 50002;
			return FALSE;
		}
		
		return $user;
	}


}
?>